﻿MPT.addAction("to_top", function(_elm) {

    var tab_name = window.location.hash.split('/')[1];

    var toTop = function() {
        var dom_top = parseInt($(document).scrollTop());
        if (dom_top > $(window).height() / 2) {
            var left = $(window).width() / 2 + 490;
            var top = ($(window).height() - 110) + $(window).scrollTop();
            top = (top > 0 ? top : 0);
            to_top_jQ.css({ "left": left, "top": top }).show();
        } else {
            to_top_jQ.hide();
        }
    }

    if (tab_name == "myspace") {

        var to_top_jQ = $(_elm);

        $(window).bind('scroll', toTop);

        to_top_jQ.click(function() {
            $(document).scrollTop(0);
        });
        
    } else {
        $(window).unbind('scroll', toTop);
    }
});
